package com.gdth.bank.widget;

import com.gdth.bank.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

/** 
 * @author  Arvin: 
 * @version 2016年9月24日 下午2:50:43 
 * 
 */
public class BankMenuPopupWindow extends MenuPopupWindow implements OnClickListener {
	/** popupmenu 中的各个item */
	private Button menu1;
	private Button menu2;
	private Button menu3;

	private onPopupMenuItemClickListener mOnPopupMenuItemClickListener;

	/**
	* 设置自定义的popupmenu布局
	*/
	public BankMenuPopupWindow(Context context, int width, int height) {
		super(LayoutInflater.from(context).inflate(R.layout.popup_windown_menu, null), width, height);
	}

	@Override
	public void initViews() {
		menu1 = (Button) findViewById(R.id.menu1);
		menu2 = (Button) findViewById(R.id.menu2);
		menu3 = (Button) findViewById(R.id.menu3);
	}

	@Override
	public void initEvents() {
		menu1.setOnClickListener(this);
		menu2.setOnClickListener(this);
		menu3.setOnClickListener(this);
	}

	@Override
	public void init() {
	
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.menu1:
				if (mOnPopupMenuItemClickListener != null) {
					mOnPopupMenuItemClickListener.onAddButtunClick();
				}
				break;
			case R.id.menu2:
				if (mOnPopupMenuItemClickListener != null) {
					mOnPopupMenuItemClickListener.onEditButtunClick();
				}
				break;
			case R.id.menu3:
				if (mOnPopupMenuItemClickListener != null) {
					mOnPopupMenuItemClickListener.onDeleteButtunClick();
				}
				break;
		}
		dismiss();
	}

	public void setOnPopupMenuItemClickListener(onPopupMenuItemClickListener listener) {
		mOnPopupMenuItemClickListener = listener;
	}

	public interface onPopupMenuItemClickListener {
		void onAddButtunClick();
		
		void onEditButtunClick();
		
		void onDeleteButtunClick();
	}
}
